package com.laihui.adapter;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.laihui.activity.R;
import com.laihui.model.InvestDetail;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;
import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

/**
 * Created by ST on 2017/7/25.
 */

public class LoanImageAdapter extends RecyclerArrayAdapter<InvestDetail.ImgsBean> {


    public LoanImageAdapter(Context context) {
        super(context);
    }

    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent ,int viewType) {

        return new LoanImageViewHolder(parent);
    }

    class LoanImageViewHolder extends BaseViewHolder<InvestDetail.ImgsBean>{
        private ImageView img1;

        public LoanImageViewHolder(ViewGroup parent) {
            super(parent, R.layout.item_loan_pic);


            img1 = $(R.id.img1);//资金详情


        }

        @Override
        public void setData(InvestDetail.ImgsBean data) {

            super.setData(data);

        }

    }
    private Bitmap returnBitmap(String url) throws MalformedURLException {
        URL fileUrl = null;
        Bitmap bitmap = null;

        try {
            fileUrl = new URL(url);
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }

        try {
            HttpURLConnection conn = (HttpURLConnection) fileUrl.openConnection();
            conn.setDoInput(true);
            conn.connect();
            InputStream is = conn.getInputStream();
            bitmap = BitmapFactory.decodeStream(is);
            is.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return bitmap;

    }

}
